package com.dcy.interpreter;

import java.util.HashMap;

/**
 * @Author：dcy
 * @Description: 加法解释器
 * @Date: 2021/2/1 9:32
 */
public class AddExpression extends SymbolExpression {

    public AddExpression(Expression left, Expression right) {
        super(left, right);
    }

    //处理相加
    //var仍然是   {a=10,b=20}..
    @Override
    public int interpreter(HashMap<String, Integer> var) {
        //super.left.interpreter(var)：返回     left表达式对应的值   a = 10
        //super.right.interpreter(var):返回  right表达式对应值    b = 20
        return super.left.interpreter(var) + super.right.interpreter(var);
    }

}
